package com.hzjy.manage.controller;

import java.util.List;

import com.hzjy.common.utils.PageData;
import com.hzjy.manage.service.HzjyDelistService;
import com.hzjy.manage.vo.HzjyDelist;
import com.hzjy.manage.vo.HzjyDelistVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hzjy.common.annotation.Log;
import com.hzjy.common.core.controller.BaseController;
import com.hzjy.common.core.domain.AjaxResult;
import com.hzjy.common.enums.BusinessType;
import com.hzjy.common.utils.poi.ExcelUtil;
import com.hzjy.common.core.page.TableDataInfo;

/**
 * 摘牌申请Controller
 *
 * @author hzjy
 * @date 2020-08-07
 */
@RestController
@RequestMapping("/manage/hzjy_delist")
public class HzjyDelistController extends BaseController
{
    @Autowired
    private HzjyDelistService hzjyDelistService;

    /**
     * 查询摘牌申请列表
     */
    @PreAuthorize("@ss.hasPermi('manage:hzjy_delist:list')")
    @GetMapping("/list")
    public TableDataInfo list(HzjyDelistVO pageData)
    {
        startPage();
        List<HzjyDelistVO> list = hzjyDelistService.selectHzjyDelistList(pageData);
        return getDataTable(list);
    }

    /**
     * 导出摘牌申请列表
     */
    /*@PreAuthorize("@ss.hasPermi('manage:hzjy_delist:export')")
    @Log(title = "摘牌申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HzjyDelistVO pageData)
    {
        List<HzjyDelistVO> list = hzjyDelistService.selectHzjyDelistList(pageData);
        ExcelUtil<HzjyDelist> util = new ExcelUtil<HzjyDelist>(HzjyDelist.class);
        return util.exportExcel(list, "delist");
    }*/

    /**
     * 获取摘牌申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:hzjy_delist:query')")
    @GetMapping(value = "/{delistId}")
    public AjaxResult getInfo(@PathVariable("delistId") Long delistId)
    {
        return AjaxResult.success(hzjyDelistService.selectHzjyDelistById(delistId));
    }

    /**
     * 新增摘牌申请
     */
    @PreAuthorize("@ss.hasPermi('manage:hzjy_delist:add')")
    @Log(title = "摘牌申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HzjyDelist hzjyDelist)
    {
        return toAjax(hzjyDelistService.insertHzjyDelist(hzjyDelist));
    }

    /**
     * 修改摘牌申请
     */
    @PreAuthorize("@ss.hasPermi('manage:hzjy_delist:edit')")
    @Log(title = "摘牌申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HzjyDelist hzjyDelist)
    {
        return toAjax(hzjyDelistService.updateHzjyDelist(hzjyDelist));
    }

    /**
     * 删除摘牌申请
     */
    @PreAuthorize("@ss.hasPermi('manage:hzjy_delist:remove')")
    @Log(title = "摘牌申请", businessType = BusinessType.DELETE)
    @DeleteMapping("/{delistIds}")
    public AjaxResult remove(@PathVariable Long[] delistIds)
    {
        return toAjax(hzjyDelistService.deleteHzjyDelistByIds(delistIds));
    }
}